Object collision prediction method and apparatus

ABSTRACT

This application provides a collision detection method and related apparatus. An image taken by a photographing unit may be used to predict whether a collision with a to-be-detected target will occur. In a current collision prediction method, a type of the to-be-detected target needs to be determined first based on the image taken by the photographing unit, which requires consuming of a large amount of computing power. In the collision prediction method provided in this application, a change trend of a distance between the to-be-detected target and a vehicle in which the apparatus is located may be determined based on the distances between the to-be-detected target and the vehicle at different moments, to predict a collision between the to-be-detected target and the vehicle. This method can improve efficiency in collision prediction and reduce energy consumption in predicting collision.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Application No.PCT/CN2019/109918, filed on Oct. 8, 2019, which claims priority toChinese Patent Application No. 201811538048.2, filed on Dec. 16, 2018.The disclosures of the aforementioned applications are herebyincorporated by reference in their entireties.

TECHNICAL FIELD

This application relates to the field of image detection, and inparticular, to a method for predicting an object collision by usingimages taken by a photographing unit, and related apparatus.

BACKGROUND

In an intelligent driver assistance system, a photographing unit isresponsible for important sensing tasks, for example, obtainingenvironment information, which is used as a basis for a computing deviceinside the vehicle to identify an obstacle type and estimate thedistance between the obstacle and the vehicle and the velocity of thevehicle. After obtaining the distance and the velocity of ato-be-detected target in front based on an image taken by thephotographing unit, the computing device may further compare thevelocity of the to-be-detected target with the velocity of the vehicle,determine whether the vehicle in which the computing device is locatedmay collide with the to-be-detected target, and when determining thatthe to-be-detected target and the vehicle may collide, predict, based ona distance between the vehicle and the to-be-detected target, when theto-be-detected target and the vehicle will collide.

Currently, for estimating a distance between a vehicle in which acomputing device is located and a to-be-detected target, usually a typeof the to-be-detected target is first determined based on informationsuch as an image taken by a photographing unit. For example, it isdetermined that the to-be-detected target is a pedestrian, a bicycle, amotorcycle, or a vehicle of a specific model. Then a real size of thetype is obtained based on data of the type stored in a database by thecomputing device. The computing device further obtains, based on thereal size of the type of the to-be-detected target and a size of theto-be-detected target in the image taken by the photographing unit, anactual distance between the to-be-detected target and the vehicle inwhich the computing device is located. Distances at different momentsbetween the to-be-detected target and the vehicle in which the computingdevice is located are compared, and when the distance between theto-be-detected target and the vehicle is gradually decreasing, it ispredicted that they may collide, or when the distance between theto-be-detected target and the vehicle is gradually increasing, it ispredicted that they do not collide.

When collision prediction is performed by using the foregoing method,the type of the to-be-detected target needs to be first determined basedon the image taken by the photographing unit, then the real size of theto-be-detected target is obtained from a prestored database based on thetype of the to-be-detected target, and the distance between theto-be-detected target and the vehicle in which the computing device islocated is obtained based on a ratio of the real size of theto-be-detected target to the size of the to-be-detected target in theimage. Then, it is determined, based on a distance change trend, whethera collision may occur. In this way, a large amount of computing power isconsumed for detecting the type of the to-be-detected target, andfurther, a specific amount of storage space is required to store thedatabase.

SUMMARY

Embodiments of this application provide a method for predicting anobject collision by using images taken by a photographing unit, and anapparatus, to resolve a prior-art problem that a large amount ofcomputing power needs to be consumed for object collision prediction.

According to a first aspect, this application provides an objectcollision prediction method, where the method is applied to a computingdevice, and the computing device is located in an object including aphotographing unit. The method includes: controlling the photographingunit to take a first image and a second image at a first moment and asecond moment respectively, where the first image and the second imageeach include a to-be-detected target and the object, and the secondmoment is later than the first moment; measuring a first distancebetween the object and the to-be-detected target in the first image anda second distance between the object and the to-be-detected target inthe second image; and predicting, based on the first distance and thesecond distance, whether the object collides with the to-be-detectedtarget, that is, when the second distance is less than the firstdistance, predicting that the object collides with the to-be-detectedtarget; or when the second distance is greater than or equal to thefirst distance, predicting that the object does not collide with theto-be-detected target.

According to the foregoing method, a change trend of the distancebetween the to-be-detected target and the object may be determined basedon distances between the to-be-detected target and the object in imagestaken at different moments, to predict whether a collision occursbetween the to-be-detected target and the object. Compared with thecurrent technology, there is no need to consume a large amount ofcomputing power for detecting a type of the to-be-detected target,thereby improving efficiency in performing collision prediction by theobject, and reducing energy consumption for performing collisionprediction by the object.

For the first aspect, in a possible implementation, when the seconddistance is less than the first distance, the method further includes:obtaining a relative velocity between the to-be-detected target and theobject based on a difference between the second distance and the firstdistance and a difference between the second moment and the firstmoment; and predicting, based on the relative velocity and the seconddistance, a time in which the object collides with the to-be-detectedtarget. According to the foregoing method, when it is predicted that theobject may collide with the to-be-detected target, the relative velocityof the to-be-detected target and the object in the image may be furthercalculated, and the time in which the collision occurs is predictedbased on the relative velocity. This may make a prediction result morespecific, and helps the object or a controller of the object takemeasures to avoid the collision.

For the first aspect, in another possible implementation, the firstmoment and the second moment are as close as possible, for example, thefirst moment and the second moment respectively correspond to previousand next frames of an image captured by the photographing unit. Thismakes a calculated relative velocity between the to-be-detected targetand the object closer to an instantaneous relative velocity of theto-be-detected target and the object at the second moment, so that thepredicted time in which the collision occurs is more accurate.

For the first aspect, in another possible implementation, thepredicting, based on the first distance and the second distance, whetherthe object collides with the to-be-detected target includes: calculatinga location difference between the object and the first image in thesecond image; and predicting, based on the first distance and a sum ofthe second distance and the location difference, whether the objectcollides with the to-be-detected target. In this way, when the pitchangle of the object changes at the second moment due to jolting oracceleration/deceleration, the obtained second distance may becorrected, thereby making a prediction result more accurate.

For the first aspect, in another possible implementation, the measuringa first distance between the object and the to-be-detected target in thefirst image and a second distance between the object and theto-be-detected target in the second image includes: obtainingtwo-dimensional borders of the to-be-detected target in the first imageand the second image; and measuring the first distance between theobject and the two-dimensional border of the to-be-detected target inthe first image and the second distance between the object and thetwo-dimensional border of the to-be-detected target in the second image.In the foregoing method, a distance between the two-dimensional bordersof the to-be-detected target and the object is used as a distancebetween the to-be-detected target and the object, thereby making aresult more accurate.

For the first aspect, in another possible implementation, when adistance between each pixel of a lower edge of the two-dimensionalborder of the to-be-detected target and the object is different, theshortest distance between a pixel included in the lower edge of thetwo-dimensional border of the to-be-detected target and the object isused as a distance between the object and the two-dimensional border ofthe to-be-detected target in the image. According to the foregoingmethod, the distance between the two-dimensional border of theto-be-detected target and the object in the image can be accuratelymeasured, thereby improving reliability of a prediction result.

For the first aspect, in another possible implementation, the object isa vehicle, and the vehicle and the to-be-detected target are located ina same lane. The object mentioned in this application may be an objectthat requires collision prediction, such as a vehicle, a ship, or arobot. However, in this implementation, the object is defined as avehicle, and the object is located in the same lane as theto-be-detected target. In this way, it is necessary to predict whetherthere is a possibility that the object collides with the to-be-detectedtarget.

For the first aspect, in another possible implementation, lane lines inthe first image and the second image are identified, where the lanelines include a first lane line and a second lane line, the first laneline and the second lane line are adjacent lane lines, and both thevehicle and the to-be-detected target are located between the first laneline and the second lane line. A transverse velocity of theto-be-detected target in the image is calculated based on a ratio of adistance between the to-be-detected target and the first lane line to asize of the two-dimensional border of the to-be-detected target in thefirst image and a ratio of a distance between the to-be-detected targetand the first lane line to a size of the two-dimensional border of theto-be-detected target in the second image. A time in which theto-be-detected target leaves the current lane is predicted based on theratio of the distance between the to-be-detected target and the firstlane line to the size of the two-dimensional border of theto-be-detected target in the second image and the transverse velocity ofthe to-be-detected target. According to the foregoing method, the timein which the to-be-detected target leaves the current lane may bedetermined based on the transverse velocity of the to-be-detectedtarget. When the time in which it takes the to-be-detected target toleave the current lane is less than the previously predicted time inwhich it takes the to-be-detected target to collide with the object, itis predicted that the collision will not happen, thereby making theprediction result more accurate.

According to a second aspect, this application provides a computingdevice, where the computing device is located on an object including aphotographing unit. The computing device includes a control module,configured to control the photographing unit to shoot a first image anda second image at a first moment and a second moment respectively, wherethe first image and the second image each include a to-be-detectedtarget and the object, and the second moment is later than the firstmoment; a processing module, configured to measure a first distancebetween the object and the to-be-detected target in the first image anda second distance between the object and the to-be-detected target inthe second image; and a prediction module, configured to predict, basedon the first distance and the second distance, whether the objectcollides with the to-be-detected target, that is, when the seconddistance is less than the first distance, predict that the objectcollides with the to-be-detected target, or when the second distance isgreater than or equal to the first distance, predict that the objectdoes not collide with the to-be-detected target.

For the second aspect, in a possible implementation, the predictionmodule is further configured to: when the second distance is less thanthe first distance, obtain a relative velocity between theto-be-detected target and the object based on a difference between thesecond distance and the first distance and a difference between thesecond moment and the first moment; and predict, based on the relativevelocity and the second distance, a time in which the object collideswith the to-be-detected target.

For the second aspect, in another possible implementation, when theprediction module predicts whether the object collides with theto-be-detected target, the prediction module is configured to: calculatea location difference between the object in the second image and theobject in the first image; and predict, based on the first distance anda sum of the second distance and the location difference, whether theobject collides with the to-be-detected target.

For the second aspect, in another possible implementation, when theprocessing module measures the first distance between the object and theto-be-detected target in the first image and the second distance betweenthe object and the to-be-detected target in the second image, theprocessing module is configured to: obtain two-dimensional borders ofthe to-be-detected target in the first image and the second image; andmeasure the first distance between the object and the two-dimensionalborder of the to-be-detected target in the first image and the seconddistance between the object and the two-dimensional border of theto-be-detected target in the second image.

For the second aspect, in another possible implementation, the object isa vehicle, and the vehicle and the to-be-detected target are located ina same lane.

For the second aspect, in another possible implementation, theprocessing module is further configured to identify lane lines in thefirst image and the second image, where the lane lines include a firstlane line and a second lane line, the first lane line and the secondlane line are adjacent lane lines, and the vehicle and theto-be-detected target are located between the first lane line and thesecond lane line; and the prediction module is further configured to:calculate a transverse velocity of the to-be-detected target based on aratio of a distance between the to-be-detected target and the first laneline to a size of the to-be-detected target in the first image and aratio of a distance between the to-be-detected target and the first laneline to a size of the to-be-detected target in the second image; andpredict, based on the ratio of the distance between the to-be-detectedtarget and the first lane line to the size of the to-be-detected targetin the second image and the transverse velocity of the to-be-detectedtarget, a time in which the to-be-detected target leaves the currentlane.

According to a third aspect, this application provides a computingdevice. The computing device includes a processor and a memory, thememory stores program code, and the processor is configured to invokethe program code in the memory to perform the collision predictionmethod according to the first aspect of this application.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1A is a schematic diagram of a possible system architectureaccording to an embodiment of this application.

FIG. 1B is a schematic diagram of another possible system architectureaccording to an embodiment of this application;

FIG. 2 is a schematic flowchart of an embodiment of this application;

FIG. 3 is a schematic diagram of a possible image taken by thephotographing unit;

FIG. 4 is a schematic diagram of another possible image taken by thephotographing unit;

FIG. 5 is a schematic flowchart of another embodiment of thisapplication;

FIG. 6 is a schematic diagram of a functional structure of a computingdevice according to an embodiment of this application; and

FIG. 7 is a schematic structural diagram of a computing device accordingto an embodiment of this application.

DESCRIPTION OF EMBODIMENTS

In a current solution of predicting whether an image taken by aphotographing unit collides with a to-be-detected target in front, atype of the to-be-detected target needs to be first identified. Thisrequires the computing device to establish and maintain an enormoussample feature database, so as to ensure that the database has data ofall possible types of the to-be-detected target. Then, image matching isperformed, based on the database, on the image taken by a camera, toidentify the to-be-detected target, and specifically, to identify a typeof the to-be-detected target and the like. After the type of theto-be-detected target is identified, for example, it is identified thatthe to-be-detected target is a vehicle of a model A, a distance betweenthe to-be-detected target and a vehicle in which the computing device islocated may be determined by comparing an actual size, recorded in thedatabase, of the vehicle of model A with a size of the to-be-detectedtarget in the image taken by the photographing unit. Then, distances atdifferent moments between the to-be-detected target and the vehicle inwhich the computing device is located are compared, and whether theto-be-detected target collides with the vehicle is predicted based on adistance change trend of the to-be-detected target and the vehicle.

In this way, an enormous sample feature database needs to beestablished, and an algorithm such as deep learning is used to identifythe type of the to-be-detected target. Therefore, a large amount ofcomputing resources and storage space needs to be consumed, and arelatively long delay is caused. In addition, it is difficult toaccurately identify a type of an object for which no data is stored inthe database, resulting in errors in subsequent distance calculations oreven possible inability to obtain distances.

In the collision prediction technical solution provided in thisapplication, a coordinate system is established in an image taken by aphotographing unit, a border of a to-be-detected target is identified,and a distance between the border of the to-be-detected target and avehicle in which a computing device is located is obtained. Herein, thedistance is measured in pixels in the image. Distances, in the image atdifferent moments, between the border of the to-be-detected target andthe vehicle in which the computing device is located are compared, todetermine a change trend of the distance between the border of theto-be-detected target and the vehicle, so as to predict whether theto-be-detected target collides with the vehicle.

Further, when a collision may occur, the computing device may furthercalculate a relative velocity between the to-be-detected target and theobject in the image based on a time difference and a change betweendistances, in the image at different moments, between the border of theto-be-detected target and the vehicle in which the computing device islocated; and predict, in real time based on the distance between theborder of the to-be-detected target and the vehicle in the image, a timein which the collision occurs. In this method, whether a collisionoccurs between the to-be-detected target and the computing device can bepredicted without identifying a type of the to-be-detected target andcalculating an actual distance between the to-be-detected target and thevehicle in which the computing device is located, and when a collisionmay occur, a time in which the to-be-detected target collides with thevehicle may be predicted. Because the type of the to-be-detected targetdoes not need to be identified, computing power and storage spaceoccupied by a sample feature database can be saved.

FIG. 1A is a schematic diagram of a possible system architectureaccording to an embodiment of this application. As shown in FIG. 1A, thevehicle 100 includes a photographing unit 102 and a computing device104. The photographing unit 102 is configured to collect an image, andmay be a monocular photographing unit or a binocular photographing unit.In actual application, the photographing unit 102 may be any one of thefollowing: an event data recorder, a camera, a camera apparatus, acamera device, or another device having a photographing function. Thephotographing unit 102 may be deployed in one or more of the followingdevices: the vehicle 100, the computing device 104, or another device(for example, a mobile phone or a computer). Herein, an example in whichthe photographing unit 102 is deployed in the vehicle 100 is used, whichdoes not constitute a limitation.

The computing device 104 is configured to obtain an image taken by thephotographing unit 102, identify a to-be-detected target in the image,and mark the identified to-be-detected target in the image using atwo-dimensional border. The computing device 104 may be furtherconfigured to identify other environment information in the image, forexample, to identify a lane line in the image. The computing device 104is further configured to use a distance between a lower edge of thetwo-dimensional border of the to-be-detected target and a head part ofthe vehicle 100 as a distance between the to-be-detected target and thevehicle 100 in the image. The distance is measured in pixels, that is,the distance between the to-be-detected target and the vehicle 100 inthe image is represented by a quantity of pixels between theto-be-detected target and the vehicle 100 in the image. Distancesbetween the to-be-detected target and the vehicle 100 in the image atdifferent moments are detected, and a change trend of the distances isanalyzed, to predict whether the to-be-detected target will collide withthe vehicle 100.

In actual application, the computing device 104 may be deployed on thevehicle 100 for use, or may be independently deployed (for details,refer to an embodiment shown in FIG. 1B). This is not limited in thepresent invention. Herein, an example in which the computing device 104is deployed in the vehicle 100 is used for illustration. The computingdevice includes but is not limited to any one of the following: a mobilephone, a tablet personal computer, a personal digital assistant (pPDA),and a mobile internet device (MID), a wearable device, an in-vehicledevice, another device that supports network communications, and thelike. It should be noted that, scenarios to which the present inventionis applicable include but are not limited to autonomous driving,obstacle detection, and any other scenario that requires targetdetection.

In actual application, the vehicle 100 may include but is not limited toa truck, a van, a train, a car, a motorcycle, an off-road vehicle, afarm vehicle, or another vehicle or device. It should be noted that, forease of description, the technical solutions in this application aredescribed by using the vehicle 100 as a main object. However, in someembodiments of this application, the photographing unit 102 and thecomputing device 104 may also be installed on other entities thatrequire collision prediction, to implement the technical solutionsprovided in this application. For example, the photographing unit 102and the computing device 104 may be installed on a ship or robot topredict whether these entities collide with to-be-detected targets infront.

In this embodiment of the present invention, any two devices of thevehicle 100, the photographing unit 102, and the computing device 104may implement inter-device network communication using a wiredcommunications technology or a wireless communications technology. Thewired communications technology may mean that two devices communicatewith each other using a network cable, an optical fiber, or the like.The wireless communications technology includes but is not limited to aglobal system for mobile communications (GSM), a general packet radioservice (GPRS), code division multiple access (CDMA), wideband codedivision multiple access (WCDMA), time-division code division multipleaccess (TD-SCDMA), long term evolution (LTE), a wireless local areanetwork (WLAN) (for example, a wireless fidelity (Wi-Fi) network),Bluetooth (BT), a global navigation satellite system (GNSS), frequencymodulation (FM), a near field communication (NFC) technology, aninfrared (IR) technology, and the like.

FIG. 1B is a schematic diagram of another possible system architectureaccording to an embodiment of this application. The system architectureincludes a photographing unit 102 and a computing device 104.

The photographing unit 102 is deployed in a local terminal device 106.The terminal device includes but is not limited to a vehicle, a mobilephone, a tablet computer, a personal digital assistant (PDA), a mobileinternet device (MID), a wearable device, and another device thatsupports network communication.

The computing device 104 is deployed on a cloud network side, forexample, deployed on a cloud server as shown in FIG. 1B. The computingdevice 104 communicates, by using a network, with the terminal device onwhich the photographing unit 102 is deployed, to obtain an imagecollected by the photographing unit 102, and further implement collisiondetection on a to-be-detected target in the image. After completingcollision detection on the to-be-detected target, the computing devicemay obtain a result of determining whether the to-be-detected targetcollides with the vehicle. Optionally, the computing device may send thedetermination of the to-be-detected target to the terminal device byusing a network, so that the terminal device learns the determinationresult of the to-be-detected target. For details about content that isnot described or shown in this embodiment of the present invention,refer to related descriptions in the embodiment in FIG. 1A. Details arenot described herein again.

FIG. 2 is a schematic flowchart of an embodiment of this application. Asshown in FIG. 2, a collision prediction method provided in thisapplication includes the following steps.

S201: A computing device 104 obtains two images taken by a photographingunit 102, and establishes a unified coordinate system on the two images.

The coordinate system uses a pixel as a length unit, and may use anypoint as an origin. This is not limited in this application. Thecomputing device 104 controls the photographing unit 102 to shoot animage once at a preset interval, and records a time for shooting theimage. The two images obtained by the computing device 104 may be imagescorresponding to two adjacent shooting times of the photographing unit102, or may be images corresponding to shooting times with a presetinterval. For ease of description, an earlier shooting time is used as afirst moment, and a later shooting time is used as a second moment.

FIG. 3 is a schematic diagram of a possible image taken by thephotographing unit 102. As shown in the figure, a pixel in an upper leftcorner of the image is used as an origin, and a coordinate system with au-axis as a horizontal axis and a v-axis as a vertical axis isestablished on the image. The coordinate system uses a pixel in theimage as a length unit. That is, a quantity of pixels between entitiesis used as a distance between the entities in the image, and for ease ofdescription, is referred to as a pixel distance below. The imageincludes a head part of the vehicle 100, a to-be-detected target, laneline information, and the like. The to-be-detected target may be anautomobile, a bicycle, a pedestrian, or the like. That theto-be-detected target is an automobile is used for description in thisapplication, but the type of the to-be-detected target is not limited.

S202: Extract two-dimensional borders of the to-be-detected target fromthe two images respectively using a computer vision detectiontechnology.

The two-dimensional border of the to-be-detected target may be obtainedby using a conventional vision algorithm such as image edge detection,or an algorithm such as deep learning. The image edge detection meansthat a status between each pixel and its neighborhood is detected todetermine whether the pixel is located on a boundary of an object, so asto extract a set of pixels located on the boundary of the object todetermine the border of the object. The image edge detection usuallyincludes the following steps: First, perform image filtering.Conventional edge detection algorithms are mainly based on first-orderand second-order derivatives of image intensity, but calculation of aderivative is sensitive to noise. Therefore, a filter needs to be usedto improve performance of a noise-related edge detector. It should benoted that while capable of reducing noise, most filters cause edgestrength loss. Therefore, a compromise needs to be made between edgeenhancement and noise reduction. Second, perform image enhancement. Abasis of edge enhancement is to determine the change of neighborhoodintensity of each point in an image. The enhancement algorithm can beused to highlight points whose neighborhood intensity changessignificantly. Edge enhancement is generally implemented by calculatinggradient amplitudes. Third, perform image detection. In an image,gradient amplitudes of many points are large. However, these points arenot all edge points in a specific application field. Therefore, aspecific method should be used to determine which points are edgepoints. Simplest edge detection determination is based on gradientamplitude. Fourth, perform image positioning. If an edge position needsto be determined in an application scenario, the edge position may beestimated based on sub-pixel resolution.

The deep learning field has a plurality of algorithms used to identify aborder of a to-be-detected target, including but not limited to any oneor a combination of the following: a convolutional neural network (CNN),a region-based convolutional neural network (RCNN), and a you only lookonce (YOLO) neural network, a single shot multibox detector (SSD), adeep feedforward neural network (DFF), and a recursive neural network(RNN). This is not limited in this application.

S203: Respectively measure a distance between the head part of thevehicle 100 and a two-dimensional border of the to-be-detected target ata first moment in the coordinate system and a pixel distance between thehead part of the vehicle 100 and a two-dimensional border of theto-be-detected target at a second moment in the coordinate system.

When the head part of the vehicle 100 comes into contact with a tailpart of the to-be-detected target, it is considered that the vehicle 100collides with the to-be-detected target.

Therefore, a pixel distance between the head part of the vehicle 100 anda lower edge of the two-dimensional border of the to-be-detected targetin the coordinate system is used as a distance between the vehicle 100and the to-be-detected target in the image.

A v-coordinate of the head part of the vehicle 100 in the imagecorresponding to the first moment is a0. For a v-coordinate of the loweredge of the two-dimensional border of the to-be-detected target, whenthe lower edge of the two-dimensional border of the to-be-detectedtarget shown in FIG. 3 is parallel to the u-axis, v-coordinates of allpixels of the lower edge of the two-dimensional border of theto-be-detected target are the same. Therefore, this coordinate is usedas the v-coordinate a1 of the lower edge of the two-dimensional borderof the to-be-detected target at the first moment.

FIG. 4 is a schematic diagram of another possible image taken by thephotographing unit 102. As shown in FIG. 4, when the lower edge of thetwo-dimensional border of the to-be-detected target is not parallel tothe u-axis, v-coordinates of all pixels on the lower edge of thetwo-dimensional border of the to-be-detected target are different. Inthis case, a pixel with a largest v-coordinate should be selected, andthis pixel is the closest to the vehicle head part of the vehicle 100.The v-coordinate of the pixel is used as the v-coordinate value a1 ofthe lower edge of the two-dimensional border of the to-be-detectedtarget at the first moment.

After the v-coordinates of the head part of the vehicle 100 and thelower edge of the two-dimensional border of the to-be-detected target atthe first moment are obtained, a pixel distance s1=a0−a1 between thevehicle 100 and the to-be-detected target at the first moment t1 iscalculated.

Similarly, a v-coordinate a2 of the head part of the vehicle 100 at thesecond moment and a v-coordinate a3 of the lower edge of thetwo-dimensional border of the to-be-detected target are obtainedaccording to the foregoing method, and a pixel distance s2=a2−a3 betweenthe vehicle 100 and the to-be-detected target at the second moment t2 iscalculated.

It should be noted that, for the distance between the vehicle 100 andthe to-be-detected target in the image, the distance between the headpart of the vehicle 100 and the lower edge of the two-dimensional borderof the to-be-detected target is used in this application. There may be aplurality of methods to express the distance between the vehicle 100 andthe to-be-detected target in the image. This is not limited in thisapplication.

S204: Predict, based on the pixel distances between the vehicle 100 andthe lower edge of the two-dimensional border of the to-be-detectedtarget at the first moment and the second moment, whether the vehicle100 and the to-be-detected target may collide.

When the pixel distance s1 between the vehicle 100 and the lower edge ofthe two-dimensional border of the to-be-detected target at the firstmoment is less than or equal to the pixel distance s2 at the secondmoment, it indicates that the distance between the vehicle 100 and thelower edge of the two-dimensional border of the to-be-detected target isincreasing or remains unchanged. In this case, the computing device 104predicts that the vehicle 100 and the to-be-detected target do notcollide, and the process ends.

When the pixel distance s1 between the vehicle 100 and the lower edge ofthe two-dimensional border of the to-be-detected target at the firstmoment is greater than the pixel distance s2 at the second moment, itindicates that the distance between the vehicle 100 and the lower edgeof the two-dimensional border of the to-be-detected target isdecreasing. In this case, the computing device 104 predicts that thevehicle 100 and the to-be-detected target may collide, and continues toperform step S205.

S205: Calculate a relative velocity of the to-be-detected target and thevehicle 100 in the coordinate system based on the distances between thelower edges of the two-dimensional border of the to-be-detected targetand the vehicle 100 at the first moment and the second moment.

The relative velocity v1=(s2−s1)/(t2−t1) of the vehicle 100 and theto-be-detected target between the first moment and the second moment maybe obtained through calculation based on the distance s2 between thelower edge of the two-dimensional border of the to-be-detected targetand the vehicle 100 at the first moment, the distance s2 between thelower edge of the two-dimensional border of the to-be-detected targetand the vehicle 100 at the second moment, and a time difference (t2−t1)between the first moment and the second moment. Herein, t1 and t2respectively indicate a time of the first moment and a time of thesecond moment.

Optionally, when an interval between the first moment and the secondmoment is small enough, especially when the first moment and the secondmoment are respectively previous and next frame images taken by thephotographing unit 102, the relative velocity v1 calculated by using theforegoing method is closer to an instantaneous relative velocity of thevehicle 100 and the to-be-detected target at the second moment, and therelative velocity v1 may be more accurate for subsequent prediction on atime in which the vehicle 100 may collide with the to-be-detectedtarget.

S206: Predict, based on the distance s2 between the lower edge of thetwo-dimensional border of the to-be-detected target and the vehicle 100at the second moment and the relative velocity v1 of the to-be-detectedtarget and the vehicle 100, a time in which the vehicle 100 may collidewith the to-be-detected target.

The computing device 104 may calculate, based on the distance s2 betweenthe lower edge of the two-dimensional border of the to-be-detectedtarget and the vehicle at the second moment and the relative velocity v1between the vehicle 100 and the to-be-detected target, the time t=s inwhich the vehicle 100 may collide with the to-be-detected target,namely, an absolute value of a result of dividing the distance s2 by therelative velocity v1. The time represents a time in which the vehicle100 and the to-be-detected target collide if they both keep the currentvelocities. With reference to step S205, when the interval between thefirst moment and the second moment is small enough, the relativevelocity v1 is closer to the instantaneous relative velocity of thevehicle 100 and the to-be-detected target at the second moment, and atime in which the vehicle 100 and the to-be-detected target collide atthe current velocities is predicted more accurately. In addition, if thevelocities of the vehicle 100 and the to-be-detected target changesubsequently, the relative velocity between the vehicle 100 and theto-be-detected target change accordingly, and the computing device 104may also calculate, based on a pixel distance between the lower edge ofthe two-dimensional border of the current to-be-detected target and thevehicle 100 and an instantaneous relative velocity of the vehicle 100and the to-be-detected target, a time in which the vehicle 100 and theto-be-detected target collide.

Optionally, when the time predicted by the computing device 104, inwhich the vehicle 100 and the to-be-detected target may collide, is lessthan a specified threshold, the computing device 104 may perform aspecific operation according to a specified program. For example, whenthe specified threshold is three seconds, if the computing device 104predicts that, at the current vehicle velocity, the vehicle 100 willcollide with the to-be-detected target within two seconds, the computingdevice 104 may control the vehicle to decelerate when a drivingcondition allows, or sound a whistle to alert the to-be-detected targetin front, or remind a driver of the vehicle 100 to intervene in drivingcontrol. This is not limited in this application.

Optionally, because a pitch angle of the vehicle 100 may change due tojolting, acceleration/deceleration, and the like when the vehicle 100 isrunning, the foregoing calculation result may deviate from the truedistance or speed. To make calculation more accurate, before thedifference between the pixel distances between the vehicle 100 and thelower edge of the two-dimensional border of the to-be-detected target atthe second moment and the first moment is calculated in steps such asS204, data corresponding to the second moment may be first correctedbased on data corresponding to the first moment.

Specifically, because the photographing unit 102 is located in thevehicle 100, theoretically the v-coordinate a0 of the head part of thevehicle 100 at the first moment is the same as the v-coordinate a2 ofthe head part of the vehicle 100 at the second moment. When a0 and a2are different, if the data corresponding to the first moment is used asa reference, it indicates that the pitch angle of the vehicle 100changes at the second moment because of jolting,acceleration/deceleration, and the like. A distance between the loweredge of the two-dimensional border of the to-be-detected targetphotographed by the photographing unit 102 and the vehicle 100 when avehicle head of the vehicle 100 is inclined upward at the second momentis greater than a distance when the vehicle head is kept horizontal.Therefore, a positive compensation amount δ needs to be added to thev-coordinate a3 of the lower edge of the two-dimensional border of theto-be-detected target at the second moment, that is, a positivecompensation amount is deducted from the distance s2 between the loweredge of the two-dimensional border of the to-be-detected target and thevehicle 100 at the second moment. A distance between the lower edge ofthe two-dimensional border of the to-be-detected target photographed bythe photographing unit 102 and the vehicle 100 when the vehicle head ofthe vehicle 100 is inclined downward at the second moment is smallerthan a distance when the vehicle head is kept horizontal. Therefore, anegative compensation amount needs to be added to the v-coordinate a3 ofthe lower edge of the two-dimensional border of the to-be-detectedtarget at the second moment, that is, a negative compensation amountneeds to be deducted from the distance s2 of the lower edge of thetwo-dimensional border of the to-be-detected target and the vehicle 100at the second moment, and subsequent calculation is performed based onthe modified distance at the second moment.

Optionally, a difference between the v-coordinate a2 of the head part ofthe vehicle 100 at the second moment and the v-coordinate a0 of the headpart of the vehicle 100 at the first moment may be used as thecompensation amount δ, that is, δ=a2−a0. When the vehicle head of thevehicle 100 is inclined upward at the second moment, the v-coordinate a2of the vehicle head part is greater than a0, and the compensation amountδ is a positive value. When the vehicle head of the vehicle 100 isinclined downward at the second moment, the v-coordinate a2 of the headpart is less than a0, and the compensation amount δ is a negative value.In this application, the distance s2 between the lower edge of thetwo-dimensional border of the to-be-detected target and the vehicle 100at the second moment may be corrected using the foregoing algorithm,thereby making a calculation result more accurate. It should be notedthat the correction of the distance s2 between the lower edge of thetwo-dimensional border of the to-be-detected target and the vehicle 100at the second moment is not limited to the foregoing method. This is notlimited in this application.

The foregoing description of the embodiments of this application isgiven by using the vehicle 100 as a main object. It should be noted thatthe technical solution provided in the embodiments of this applicationmay be applied not only to the field of intelligent vehicle driving, butalso to the fields of robots, ships, and the like as a technicalsolution of collision prediction. The application scenarios are notlimited in this application.

FIG. 5 is a schematic flowchart of another embodiment of thisapplication.

In the schematic flowchart shown in FIG. 2, this application provides asolution of predicting whether a vehicle 100 collides with ato-be-detected target in front and a time when a collision occurs. Ifthe to-be-detected target is changing lanes, and a time used forchanging the lane is less than a time that is predicted for the vehicle100 to collide with the to-be-detected target, even if both the vehicle100 and the to-be-detected target keep current velocities, they will notcollide. As shown in FIG. 5, this embodiment includes the followingsteps:

S501: A computing device 104 obtains two images taken by a photographingunit 102, and establishes a unified coordinate system on the two images.

S502: Extract two-dimensional borders and lane line information of ato-be-detected target from the two images by using a computer visiondetection technology.

The two-dimensional borders of the to-be-detected target and lane lineinformation of a lane in which the to-be-detected target and the vehicle100 are located are extracted from the two images by using the computervision detection technology described in detail in step S202, where theto-be-detected target is located between a first lane line and a secondlane line. The first lane line may be used to represent a lane line onthe left of the to-be-detected target, and the second lane line may beused to represent a lane line on the right of the to-be-detected target.Alternatively, the first lane line may be used to represent a lane lineon the right of the to-be-detected target, and the second lane may beused to represent a lane line on the left of the to-be-detected target.This is not limited in this application.

S503: Calculate ratios r1 and r2 of distances between thetwo-dimensional borders of the to-be-detected target and the first laneline and to lengths of a lower edge of the two-dimensional border at thefirst moment and the second moment.

A size of an object that is farther away from the photographing unit 102appears smaller in an image taken by the photographing unit 102.Therefore, when a distance between the to-be-detected target and thevehicle 100 changes, both the size of the two-dimensional border of theto-be-detected target in the image and the distance between thetwo-dimensional border of the to-be-detected target and a lane linechange accordingly. To resolve this problem, in this application,calculation is performed by using the ratio r1 of the distance betweenthe two-dimensional border of the to-be-detected target and the firstlane line to the length of the lower edge of the two-dimensional borderof the to-be-detected target. This may eliminate impact on a calculationresult caused by a change of a size of the to-be-detected target in theimage due to a difference in distances between the to-be-detected targetand the photographing unit 102. Similarly, a ratio of the distancebetween the two-dimensional border of the to-be-detected target and thefirst lane line to another size of the two-dimensional border of theto-be-detected target may be alternatively selected for calculation.This is not limited in this application.

Because it is considered that the to-be-detected target has completedlane change only when the to-be-detected target completely leaves thelane in which the to-be-detected target is located, in this embodiment,a pixel that is of the two-dimensional border of the to-be-detectedtarget and that has a largest distance to the first lane line should beselected, and the distance between the pixel and the first lane line isconsidered as the distance between the two-dimensional border of theto-be-detected target and the first lane line. Specifically, when theto-be-detected target changes a lane to the left, a left lane line isused as the first lane line, and a distance between a right edge of thetwo-dimensional border of the to-be-detected target and the first laneline is used as the distance between the two-dimensional border of theto-be-detected target and the first lane line. When the to-be-detectedtarget changes a lane to the right, a right lane line is used as thefirst lane line, and a distance between a left edge of thetwo-dimensional border of the to-be-detected target and the first laneline is used as the distance between the two-dimensional border of theto-be-detected target and the first lane line.

Similarly, the distance between the two-dimensional border of theto-be-detected target and the first lane line at the second moment isobtained, and the ratio r2 of the distance between the two-dimensionalborder of the to-be-detected target and the first lane line at thesecond moment to the length of the lower edge of the two-dimensionalborder is calculated.

S504: Calculate a transverse velocity v2 of the to-be-detected targetbased on a change of the ratios of the distances between thetwo-dimensional border of the to-be-detected target and the first laneline to the lengths of the lower edge of the two-dimensional border atthe first moment and the second moment.

The transverse velocity v2=(r2−r1)/(t2−t1) of the to-be-detected targetmay be obtained based on the ratio r1 of the distance between thetwo-dimensional border of the to-be-detected target and the first laneline to the length of the lower edge of the two-dimensional border atthe first moment, the ratio r2 of the distance between thetwo-dimensional border of the to-be-detected target and the first laneline to the length of the lower edge of the two-dimensional border atthe second moment, and a time difference (t2−t1) between the secondmoment and the first moment.

Optionally, when an interval between the first moment and the secondmoment is small enough, especially when the first moment and the secondmoment are respectively previous and next frame images taken by thephotographing unit 102, the transverse velocity v2 of the to-be-detectedtarget calculated by using the foregoing method is closer to aninstantaneous transverse velocity of the to-be-detected target at thesecond moment, and the transverse velocity v2 may be more accurate forsubsequent prediction on a time in which the to-be-detected targetcompletes lane change.

S505: Predict, based on the ratio of the distance between thetwo-dimensional border of the to-be-detected target and the first laneline to the length of the lower edge of the two-dimensional border ofthe to-be-detected target at the second moment and the transversevelocity of the to-be-detected target, when the to-be-detected targetcompletes lane change.

The distance between the two-dimensional border of the to-be-detectedtarget and the first lane line is defined in this embodiment as adistance between the first lane line and a pixel that is of thetwo-dimensional border of the to-be-detected target and that has alargest distance to the first lane line. Therefore, a time in which theto-be-detected target completely leaves the lane may be obtained basedon the distance and the transverse velocity of the to-be-detectedtarget. With reference to the time in which the vehicle 100 collideswith the to-be-detected target as predicted in step S206, if the time inwhich the to-be-detected target completely leaves the lane is less thanthe time in which the vehicle 100 collides with the to-be-detectedtarget, it may be predicted that the to-be-detected target and thevehicle 100 do not collide when they both keep current velocities.

FIG. 6 is a schematic diagram of a functional structure of a computingdevice used for collision prediction according to an embodiment of thisapplication. The computing device is located in an object that includesa photographing unit. As shown in FIG. 6, the computing device 600includes a control module 610, a processing module 620, and a predictionmodule 630.

The control module 610 is configured to shoot a first image and a secondimage at a first moment and a second moment respectively, where thefirst image and the second image each include a to-be-detected targetand the object, and the second moment is later than the first moment.

The processing module 620 is configured to measure a first distancebetween the object and the to-be-detected target in the first image anda second distance between the object and the to-be-detected target inthe second image.

The prediction module 630 is configured to predict, based on the firstdistance and the second distance, whether the object collides with theto-be-detected target. To be specific, when the second distance is lessthan the first distance, it is predicted that the object collides withthe to-be-detected target; or when the second distance is greater thanor equal to the first distance, it is predicted that the object does notcollide with the to-be-detected target.

The computing device 600 is further configured to perform other steps ofcollision prediction shown in FIG. 2 and FIG. 5. Specifically, thecontrol module 610 is configured to perform the operation of controllingthe photographing unit to shoot an image in steps S201 and S501, theprocessing module 620 is configured to perform the operation ofestablishing a coordinate system in steps S201 and S501, and steps S202,S203, S502, and S503, and the prediction module 630 is configured toperform steps S204, S205, S206, S504, and S505. Details are notdescribed herein.

FIG. 7 is a schematic structural diagram of a computing device 700 forcollision prediction according to an embodiment of this application. Thecomputing device 700 in this embodiment may be one exampleimplementation of a system in the foregoing embodiments.

As shown in FIG. 7, the computing device 700 includes a processor 701,and the processor 701 is connected to a memory 705. The processor 701may be computational logic such as a field programmable gate array(FPGA), a digital signal processor (DSP), or a combination of anycomputational logic. The processor 701 may be a single-core processor ora multi-core processor.

The memory 705 may be a RAM memory, a flash memory, a ROM memory, anEPROM memory, an EEPROM memory, a register, or a storage medium in anyother form known in the art. The memory may be configured to store aprogram instruction. When the program instruction is executed by theprocessor 701, the processor 701 performs the method in the foregoingembodiment.

A bus connection 709 is configured to transfer information betweencomponents of a communications apparatus. The bus connection 709 may beconnected in a wired connection manner or a wireless connection manner.This is not limited in this application. The connection 709 is furtherconnected to a network interface 704.

The network interface 704 implements communication with another deviceor a network 711 by using, for example but not limited to, a connectionapparatus such as a cable or an electrical twisted wire. The networkinterface 704 may also be interconnected with the network 711 in awireless manner.

Some features in this embodiment of this application may beimplemented/supported by the processor 701 by executing a programinstruction or software code in the memory 705. Software componentsloaded on the memory 705 may be summarized in terms of functions orlogic, for example, the control module, the processing module, and theprediction module shown in FIG. 6.

In an embodiment of this application, after the memory 705 loads theprogram instruction, the processor 701 executes a transaction related tothe foregoing function/logical module in the memory.

In addition, FIG. 7 shows merely an example of a computing device 700.The computing device 700 may include more or fewer components than thoseshown in FIG. 7, or may have different component configuration manners.In addition, various components shown in FIG. 7 may be implemented byhardware, software, or a combination of hardware and software. Forexample, the memory and the processor may be implemented in one module.An instruction in the memory may be written into the memory in advance,or may be loaded in a subsequent execution process of the processor.

1. An object collision prediction method, wherein the method is appliedto a computing device, the computing device is located in an objectcomprising a photographing unit, and the method comprises: adjusting thephotographing unit so that images taken by the photographing unitinclude a front portion of the object; controlling the photographingunit to shoot a first image and a second image at a first moment and asecond moment respectively, wherein the first image and the second imageeach comprise a to-be-detected target and the front portion of theobject, and the second moment is later than the first moment; measuringa first distance between the object and the to-be-detected target in thefirst image and a second distance between the object and theto-be-detected target in the second image; and predicting, based on thefirst distance and the second distance, whether the object collides withthe to-be-detected target.
 2. The method according to claim 1, whereinwhen the second distance is less than the first distance, the methodfurther comprises: obtaining a relative velocity between theto-be-detected target and the object based on a difference between thesecond distance and the first distance and a difference between thesecond moment and the first moment; and predicting, based on therelative velocity and the second distance, a time in which the objectcollides with the to-be-detected target.
 3. The method according toclaim 1, wherein the predicting, based on the first distance and thesecond distance, whether the object collides with the to-be-detectedtarget comprises: calculating a location difference between the objectin the second image and the object in the first image; and predicting,based on the first distance and a sum of the second distance and thelocation difference, whether the object collides with the to-be-detectedtarget.
 4. The method according to claim 1, wherein the measuring afirst distance between the object and the to-be-detected target in thefirst image and a second distance between the object and theto-be-detected target in the second image comprises: obtainingtwo-dimensional borders of the to-be-detected target in the first imageand the second image; and measuring the first distance between theobject and the two-dimensional borders of the to-be-detected target inthe first image and the second distance between the object and thetwo-dimensional border of the to-be-detected target in the second image.5. The method according to claim 4, wherein when a distance between eachpixel of a lower edge of the two-dimensional border of theto-be-detected target and the object is different, a shortest distancebetween a pixel comprised in the lower edge of the two-dimensionalborder of the to-be-detected target and the object is used as a distancebetween the object and the two-dimensional border of the to-be-detectedtarget in the image.
 6. The method according to claim 1, wherein theobject is a vehicle, and the vehicle and the to-be-detected target arelocated in a same lane.
 7. The method according to claim 6, wherein themethod further comprises: identifying lane lines in the first image andthe second image, wherein the lane lines comprise a first lane line anda second lane line, the first lane line and the second lane line areadjacent lane lines, and the vehicle and the to-be-detected target arelocated between the first lane line and the second lane line;calculating a transverse velocity of the to-be-detected target based ona ratio of a distance between the to-be-detected target and the firstlane line to a size of the to-be-detected target in the first image anda ratio of a distance between the to-be-detected target and the firstlane line to a size of the to-be-detected target in the second image;and predicting, based on the ratio of the distance between theto-be-detected target and the first lane line to the size of theto-be-detected target in the second image and the transverse velocity ofthe to-be-detected target, a time in which the to-be-detected targetleaves the current lane.
 8. A computing device, wherein the computingdevice is located in an object comprising a photographing unit, and thecomputing device comprises: a processor; and a computer-readable storagemedium coupled to the processor and storing programming instructions forexecution by the processor, wherein the programming instructionsinstruct the processor to control the photographing unit to shoot afirst image and a second image at a first moment and a second momentrespectively, wherein the first image and the second image each comprisea to-be-detected target and the object, and the second moment is laterthan the first moment; measure a first distance between the object andthe to-be-detected target in the first image and a second distancebetween the object and the to-be-detected target in the second image;and predict, based on the first distance and the second distance,whether the object collides with the to-be-detected target.
 9. Thecomputing device according to claim 8, wherein the programminginstructions instruct the processor to: when the second distance is lessthan the first distance, obtain a relative velocity between theto-be-detected target and the object based on a difference between thesecond distance and the first distance and a difference between thesecond moment and the first moment; and predict, based on the relativevelocity and the second distance, a time in which the object collideswith the to-be-detected target.
 10. The computing device according toclaim 8, wherein the programming instructions instruct the processor to:calculate a location difference between the object in the second imageand the object in the first image; and predict, based on the firstdistance and a sum of the second distance and the location difference,whether the object collides with the to-be-detected target.
 11. Thecomputing device according to claim 8, wherein the programminginstructions instruct the processor to: obtain two-dimensional bordersof the to-be-detected target in the first image and the second image;and measure the first distance between the object and thetwo-dimensional border of the to-be-detected target in the first imageand the second distance between the object and the two-dimensionalborder of the to-be-detected target in the second image.
 12. Thecomputing device according to claim 8, wherein the object is a vehicle,and the vehicle and the to-be-detected target are located in a samelane.
 13. The computing device according to claim 12, wherein theprogramming instructions instruct the processor to: identify lane linesin the first image and the second image, wherein the lane lines comprisea first lane line and a second lane line, the first lane line and thesecond lane line are adjacent lane lines, and the vehicle and theto-be-detected target are located between the first lane line and thesecond lane line; and calculate a transverse velocity of theto-be-detected target based on a ratio of a distance between theto-be-detected target and the first lane line to a size of theto-be-detected target in the first image and a ratio of a distancebetween the to-be-detected target and the first lane line to a size ofthe to-be-detected target in the second image; and predict, based on theratio of the distance between the to-be-detected target and the firstlane line to the size of the to-be-detected target in the second imageand the transverse velocity of the to-be-detected target, a time inwhich the to-be-detected target leaves the current lane.
 14. Anon-transitory computer readable medium comprising computer programcodes stored thereon, executable by one or more processors for an objectcollision prediction, the computer program codes including: instructionsfor controlling the photographing unit to shoot a first image and asecond image at a first moment and a second moment respectively, whereinthe first image and the second image each comprise a to-be-detectedtarget and the object, and the second moment is later than the firstmoment; instructions for measuring a first distance between the objectand the to-be-detected target in the first image and a second distancebetween the object and the to-be-detected target in the second image;and instructions for predicting, based on the first distance and thesecond distance, whether the object collides with the to-be-detectedtarget.
 15. The non-transitory computer readable medium according toclaim 14, the computer program codes including: instructions forobtaining a relative velocity between the to-be-detected target and theobject based on a difference between the second distance and the firstdistance and a difference between the second moment and the first momentwhen the second distance is less than the first distance; andinstructions for predicting, based on the relative velocity and thesecond distance, a time in which the object collides with theto-be-detected target.
 16. The non-transitory computer readable mediumaccording to claim 14, the instructions for predicting, based on thefirst distance and the second distance, whether the object collides withthe to-be-detected target comprises: instructions for calculating alocation difference between the object in the second image and theobject in the first image; and instructions for predicting, based on thefirst distance and a sum of the second distance and the locationdifference, whether the object collides with the to-be-detected target.17. The non-transitory computer readable medium according to claim 14,the instructions for measuring a first distance between the object andthe to-be-detected target in the first image and a second distancebetween the object and the to-be-detected target in the second imagecomprises: instructions for obtaining two-dimensional borders of theto-be-detected target in the first image and the second image; andinstructions for measuring the first distance between the object and thetwo-dimensional borders of the to-be-detected target in the first imageand the second distance between the object and the two-dimensionalborder of the to-be-detected target in the second image.
 18. Thenon-transitory computer readable medium according to claim 17, whereinwhen a distance between each pixel of a lower edge of thetwo-dimensional border of the to-be-detected target and the object isdifferent, a shortest distance between a pixel comprised in the loweredge of the two-dimensional border of the to-be-detected target and theobject is used as a distance between the object and the two-dimensionalborder of the to-be-detected target in the image.
 19. The non-transitorycomputer readable medium according to claim 14, wherein the object is avehicle, and the vehicle and the to-be-detected target are located in asame lane.
 20. The non-transitory computer readable medium according toclaim 19, the computer program codes including: instructions foridentifying lane lines in the first image and the second image, whereinthe lane lines comprise a first lane line and a second lane line, thefirst lane line and the second lane line are adjacent lane lines, andthe vehicle and the to-be-detected target are located between the firstlane line and the second lane line; instructions for calculating atransverse velocity of the to-be-detected target based on a ratio of adistance between the to-be-detected target and the first lane line to asize of the to-be-detected target in the first image and a ratio of adistance between the to-be-detected target and the first lane line to asize of the to-be-detected target in the second image; and instructionsfor predicting, based on the ratio of the distance between theto-be-detected target and the first lane line to the size of theto-be-detected target in the second image and the transverse velocity ofthe to-be-detected target, a time in which the to-be-detected targetleaves the current lane.